function loadAdmin()
{
//	alert (AdminType);
	$.post
	('model/ajax/admin.php',
		{
			UserID:UserID,
			SessionID:SessionID,
			Type:AdminType
		},
		loadAdminSuccess
	)
	
}

function loadAdminSuccess(data)
{
	$("#admin").slideDown(2000);
	$("#admin-result-container").html(data);
	
	$("#menu-admin-sessions").unbind();
	$("#menu-admin-sessions").click(showSessions);

	$("#menu-admin-users").unbind();
	$("#menu-admin-users").click(showUsers);

	$("#menu-admin-modifyusers").unbind();
	$("#menu-admin-modifyusers").click(showModifyUsers);
	
	$(".admin-modifyusers-user").click(editUser);

	$("#admin li").hover(function(){$(this).addClass("li-hover");},function(){$(this).removeClass("li-hover");});

	
//	alert (data);
}

function showSessions()
{
	AdminType = 'sessions';
	loadAdmin();
}

function showUsers()
{
	AdminType = 'users';
	loadAdmin();
}

function showModifyUsers()
{
	AdminType = 'modifyUsers';
	loadAdmin();
}

function editUser()
{
//	alert ("Edit User" + $(this).attr("id"));
	idArr=$(this).attr("id").split("-");
	userID = idArr[3];
//	alert (userID);


	$.post
	('model/ajax/admin-modifyuser.php',
		{
			UserID:UserID,
			SessionID:SessionID,
			Type:AdminType,
			ModifyUserID:userID
		},
		onceLoadedEditUser
	)
}

function onceLoadedEditUser(data)
{
//	alert(data);
	
	$('#admin-modifyusers-edit-dialog').dialog
	(
		{
       		autoOpen: false,
       		modal: true,
       		title: "Modify User Information",
			height: 380,
			width: 450,
       		buttons: 
       		{
           		'OK' : function() {
           			url='model/ajax/admin-modifyuser-save.php';
					$.post
					(
						url,
						{
							SnapUserID:$("#admin-modifyusers-user-edit-value-SnapUserID").val(),
							LongName:$("#admin-modifyusers-user-edit-value-longname").val(),
							ShortName:$("#admin-modifyusers-user-edit-value-shortname").val(),
							Password:$("#admin-modifyusers-user-edit-value-password").val(),
							Email:$("#admin-modifyusers-user-edit-value-email").val(),
							GroupID:$("#admin-modifyusers-user-edit-value-groupname").val(),
						},
						onceLoadedSaveUser
					);
//					$("#musiclist-edit").hide();
           			$(this).dialog('destroy');},
           			
       	    	'Cancel': function() {
       	    		$(this).dialog('destroy');}
       		},
       		open: function(event,ui) 
       		{
				$("#admin-modifyusers-edit-dialog").html(data);
       		}
   		}
   	);
   
	$('#admin-modifyusers-edit-dialog').dialog('open');

	
	
/*	

	$(".admin-modifyusers-value-text").click(
		function()
		{
			switch(this.id)
			{
				case 'musiclist-edit-value-introit':
				case 'musiclist-edit-value-responses':
				case 'musiclist-edit-value-mass':
				case 'musiclist-edit-value-canticles':
				case 'musiclist-edit-value-anthem':
//					alert(this.id)
					break;
					
				default:
					break;
				
			}

		});
	
*/
	$("#admin-modifyusers-edit-dialog").show();
}

function onceLoadedSaveUser()
{
	AdminType = 'modifyUsers';
	loadAdmin();
}
